package com.duvee.uiautomator;

import java.io.IOException;

import jxl.read.biff.BiffException;
import jxl.write.WriteException;
import android.os.RemoteException;

import com.android.uiautomator.core.UiObjectNotFoundException;
import com.duvee.uiautomator.interfaces.BaseTestCase;

/**
 * lbt拍照功能
 * 
 * @author Administrator
 * 
 */
public class LBTTakePhotoCase extends BaseTestCase {
	String startActivity = "com.shenzhou.lbt/com.shenzhou.lbt.activity.main.WelcomeActivity";
	String appName = "lbt";

	@Override
	public void caseInfo() {
		caseList.add("登录");
		caseList.add("拍照");
		caseList.add("退出");
	}

	@Override
	public void event() {
		try {
			device.wakeUp();
			device.pressHome();
			startApp(startActivity);
			phoneInfo = getProductInfo(phoneModel);
			obj = getObjectByID("com.shenzhou.lbt:id/login_edtUsername");
			obj.clickBottomRight();
			obj.setText("15093131283");
			device.pressBack();
			obj = getObjectByID("com.shenzhou.lbt:id/login_edtPassword");
			obj.setText("6666666");
			device.pressBack();
			obj = getObjectByID("com.shenzhou.lbt:id/login_btnEnter");
			takeScreenShot(phoneModel + "_lbt_login.png");
			obj.clickAndWaitForNewWindow(5000);
			obj = getObjectByText("乐贝通幼儿园");
			obj.waitForExists(5000);
			sleep(5000);
			result = obj.exists() ? "通过" : "不通过";
			setResultBean(phoneModel, "登录模块", "登录，进入到角色权限。", result);
			takeScreenShot(phoneModel + "_lbt_choiceRole.png");
			obj.click();
			obj = getObjectByText("园长");
			obj.click();
			obj = getObjectByID("com.shenzhou.lbt:id/common_title_level_one_btn");
			obj.clickAndWaitForNewWindow(5000);
			obj = getObjectByText("圈子");
			result = obj.exists() ? "通过" : "不通过";
			setResultBean(phoneModel, "选取角色", "选角色后，看是否进入主模块", result);
			takeScreenShot(phoneModel + "_lbt_mainActivity.png");
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (UiObjectNotFoundException e1) {
			e1.printStackTrace();
		} finally {
			try {
				writeResult(list, phoneModel + "_lbt.xls");
			} catch (BiffException e) {
				e.printStackTrace();
			} catch (WriteException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
